import { STColumnBadge, STColumnTag } from '@delon/abc/st';
const TENANT_KEY_PREFIX = 'X-CURRENT-TENANT-';
const ROLE_PAGE_PARAMS_CACHE_KEY = 'role:page:params_';

const OAUTH_CLIENT_ID = 'auth-code-client';
const PKCE_CLIENT_ID = 'pkce-client';
const OAUTH_CLIENT_SECRET = '123456';
const PKCE_REDIRECT_URI = 'http://www.ukulele.com:4200/passport/pcke';
const OAUTH_REDIRECT_URI = 'http://www.ukulele.com:4200/passport/oauth2';

export { OAUTH_CLIENT_ID, PKCE_CLIENT_ID, OAUTH_CLIENT_SECRET, PKCE_REDIRECT_URI, OAUTH_REDIRECT_URI };

/** 菜单级别 */
const MENU_GRAD_ENMU = [
  { label: '运维级', value: 0 },
  { label: '平台级', value: 5 },
  { label: '组织级', value: 10 },
  { label: '业务级', value: 15 }
];

/**验证方法 */
const CLIENT_AUTHENTICATION_METHOD = [
  { label: 'none', value: 'none' },
  { label: 'client_secret_basic', value: 'client_secret_basic' },
  { label: 'client_secret_post', value: 'client_secret_post' },
  { label: 'client_secret_jwt', value: 'client_secret_jwt' },
  { label: 'private_key_jwt', value: 'private_key_jwt' }
];

/**授权类型 */
const AUTHORIZATION_GRANT_TYPE = [
  { label: 'authorization_code', value: 'authorization_code' },
  { label: 'refresh_token', value: 'refresh_token' },
  { label: 'client_credentials', value: 'client_credentials' },
  { label: 'urn:ietf:params:oauth:grant-type:jwt-bearer', value: 'urn:ietf:params:oauth:grant-type:jwt-bearer' },
  { label: 'urn:ietf:params:oauth:grant-type:device_code', value: 'urn:ietf:params:oauth:grant-type:device_code' }
];

export { CLIENT_AUTHENTICATION_METHOD, AUTHORIZATION_GRANT_TYPE };

/**启用禁用状态 */
const DELETED_STATUS_ENUM = [
  { label: '全部', value: null },
  { label: '启用', value: false },
  { label: '禁用', value: true }
];

/**启用禁用状态 */
const DELETED_STATUS_BADGE: STColumnBadge = {
  false: { text: '启用', color: 'success' },
  true: { text: '禁用', color: 'error' }
};

/**用户标签 */
const USER_LABEL_ENUM = [
  { label: '全部', value: '' },
  { label: '平台', value: 'platform' },
  { label: '组织', value: 'org' },
  { label: '用户', value: 'user' }
];

/**用户标签 */
const USER_LABEL_TAG: STColumnTag = {
  user: { text: '用户', color: 'green' },
  operator: { text: '超管', color: 'red' },
  org: { text: '组织', color: 'blue' },
  platform: { text: '平台', color: 'orange' }
};

/**平台类型 */
const PLAT_SOURCE_ENUM = [
  { label: '全部', value: '' },
  { label: '微信网页', value: 0 },
  { label: '微信小程序', value: 1 },
  { label: '微信公众号', value: 2 }
];
/**平台类型 */
const PLAT_SOURCE_TAG: STColumnTag = {
  0: { text: '微信网页', color: 'green' },
  1: { text: '微信小程序', color: 'green' },
  2: { text: '微信公众号', color: 'green' }
};

/**角色类型 */
const ROLE_TYPE_TAG: STColumnTag = {
  10: { text: '业务角色', color: 'green' },
  5: { text: '平台角色', color: 'blue' },
  0: { text: '运维角色', color: 'red' }
};

/**角色类型 */
const ROLE_TYPE_ENUM = [
  { label: '全部', value: -1 },
  { label: '运维角色', value: 0 },
  { label: '平台角色', value: 5 },
  { label: '业务角色', value: 10 }
];

/**参数类型 */
const PARAM_TYPE_TAG: STColumnTag = {
  10: { text: '业务类型', color: 'green' },
  5: { text: '系统类型', color: 'red' }
};

/*参数类型 */
const PARAM_TYPE_ENUM = [
  { label: '全部', value: 0 },
  { label: '系统类型', value: 5 },
  { label: '业务类型', value: 10 }
];

/**资源方法 */
const RESOURCE_METHOD_ENUM = [
  { label: '不限', value: '*', color: 'purple' },
  { label: 'GET', value: 'GET', color: 'blue' },
  { label: 'POST', value: 'POST', color: 'green' },
  { label: 'PUT', value: 'PUT', color: 'orange' },
  { label: 'DELETE', value: 'DELETE', color: 'red' }
];
/**资源方法 */
const RESOURCE_METHOD_TAG: STColumnTag = {
  '*': { text: '不限', color: 'success' },
  GET: { text: 'GET', color: 'processing' },
  POST: { text: 'POST', color: 'default' },
  PUT: { text: 'PUT', color: 'warning' },
  DELETE: { text: 'DELETE', color: 'error' }
};

/**菜单类型 */
const MENU_TYPE_ENUM = [
  { label: '网页', value: 0 },
  { label: '跨平台(uniapp)', value: 5 },
  { label: '跨平台(flutter)', value: 10 },
  { label: '安卓手机', value: 15 },
  { label: '苹果', value: 20 },
  { label: '安卓平板', value: 25 },
  { label: 'IPAD', value: 30 },
  { label: '微信小程序', value: 35 },
  { label: '微信公众号', value: 40 },
  { label: 'Windows客户端', value: 45 },
  { label: 'MAC客户端', value: 50 }
];

export { TENANT_KEY_PREFIX, ROLE_PAGE_PARAMS_CACHE_KEY };
export {
  MENU_GRAD_ENMU,
  USER_LABEL_ENUM,
  DELETED_STATUS_ENUM,
  DELETED_STATUS_BADGE,
  USER_LABEL_TAG,
  ROLE_TYPE_TAG,
  ROLE_TYPE_ENUM,
  RESOURCE_METHOD_ENUM,
  PARAM_TYPE_ENUM,
  PARAM_TYPE_TAG,
  RESOURCE_METHOD_TAG,
  PLAT_SOURCE_ENUM,
  PLAT_SOURCE_TAG,
  MENU_TYPE_ENUM
};
